<?php
class Comun_model extends CI_Model
{

    public function __construct()
    {
        // Call the Model constructor
        parent::__construct();
        $this->load->database();
    }



    public function get_sabiasqueById($idCategoria = '0')
    {
        $sql = "" .
            "SELECT c.cod_blog ,  " .
            "       c.titulo, " .
            "       c.contenido " .
            "FROM   blog c " .
            " where c.cod_blog = ".$idCategoria ;


        $query = $this->db->query($sql);

        $result = array();
        foreach ($query->result_array() as $row)
        {
            $result[] = $row;
        }
        if(count($result)==0){
            return array();
        }
        return $result[0];
    }

    public function get_sabiasque()
    {
        $sql = "" .
            "SELECT c.cod_blog ,  " .
            "       titulo, " .
            "       contenido " .
            "FROM   blog c ".
            " WHERE c.tipo=1 " ;

        $query = $this->db->query($sql);

        $result = array();
        foreach ($query->result_array() as $row)
        {
            $result[] = $row;
        }
        return $result;
    }

    public function get_novedadById($idCategoria = '0')
    {
        $sql = "" .
            "SELECT * " .
            "FROM   novedades c " .
            " where c.cod_novedad = ".$idCategoria ;


        $query = $this->db->query($sql);

        $result = array();
        foreach ($query->result_array() as $row)
        {
            $result[] = $row;
        }
        if(count($result)==0){
            return array();
        }
        return $result[0];
    }

    public function get_novedades()
    {
        $sql = "" .
            "SELECT * " .
            "FROM   novedades c ";

        $query = $this->db->query($sql);

        $result = array();
        foreach ($query->result_array() as $row)
        {
            $result[] = $row;
        }
        return $result;
    }

    public function get_tips_interes()
    {
        $sql = "" .
            "SELECT c.cod_blog ,  " .
            "       c.titulo, " .
            "       c.contenido " .
            "FROM   blog c ".
             " WHERE c.tipo=2 " ;

        $query = $this->db->query($sql);

        $result = array();
        foreach ($query->result_array() as $row)
        {
            $result[] = $row;
        }
        return $result;
    }


}

?>